// pages/ui/my/my.js
var that;
var storeArray;

Page({

  /**
   * 页面的初始数据
   */
  data: {
    head_bg: '../../../res/top_bg.png',
    userHead: '../../../res/user-head.jpeg',
    userName: '路小猫',
    signIcon: '../../../res/icon_sign.png',
    dialogShow:false,//弹窗遮罩
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    that = this;
    storeArray = [];
    that.getStoreList();

    //获取用户信息
    wx.getUserInfo({
      success: function (res) {
        console.log(res);
        var avatarUrl = 'userInfo.avatarUrl';
        var nickName = 'userInfo.nickName';
        that.setData({
          userHead: res.userInfo.avatarUrl,
          userName: res.userInfo.nickName,
        })
      }
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },

  /**
   * 附近门店列表
   */
  getStoreList: function () {
    for(var i=0;i<3;i++) {
      storeArray.push({
        shopImg: '../../../res/brand.jpg',
        shopName: '莫拉克电动车',
        shopDistance: '300',
        shopAddr: '浙江省杭州市江干区东港嘉苑三区底商59号'
      })
    }
    that.setData({
      storeArray: storeArray,
    })
  },
  /**
   * 关闭弹窗
   */
  clickDialog: function() {
    that.setData({
      dialogShow: false,
      isShowSign: false,
      signSucImg:'',
      isShowBag: false,
      redBagImg: '',
      isShowBagOpen: false,
      redBagOpenImg:'',
      isShowClose: false,
      close: ''
    })
  },
  /**
   * 签到
   */
  clickSign: function () {
    that.setData({
      dialogShow: true,
      isShowSign: true,
      signSucImg:'../../../res/signin.png',
      isShowClose: true,
      close: '../../../res/icon_close.png',
    })
  },
  /**
   * 抢红包
   */
  clickGrabRed: function () {
    that.setData({
      dialogShow: true,
      isShowBag: true,
      redBagImg: '../../../res/red_get.png'
    })
  },
  /**
   * 已抢到红包
   */
  clickRed: function() {
    that.setData({
      isShowBag: false,
      redBagImg: '',
      isShowBagOpen: true,
      redBagOpenImg: true,
      redBagOpenImg: '../../../res/red_open.png',
      isShowClose: true,
      close: '../../../res/icon_close.png',
    })
  }

})